package cn.zhizihua.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 购物车项
 * cart表中 每一条记录就是一个购物车项
 *      cartId      foodId      businessId      userId      quantity
 *         1           1            1             1             2
 *                  胡辣汤       白家胡辣汤         张三            2
 *         2           2            1             1             1
 *                  油饼         白家胡辣汤         张三            1
 *
 * 涉及4张表联查
 */

@Data
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) //关联查询结果展示包含非空的字段  （如果字段是空的，转JSON时自动忽略掉了）
public class CartItem {

    private Integer cartId;
    private Integer foodId;
    private Integer businessId;
    private Integer userId;
    private Integer quantity;


    //所属餐品、商家、用户
    private Food food;   //foodId 对应查询到餐品名称
    private Business business;  //businessId 对应查询到商家名称
    private User user;   //userId  对应查询到用户名称


    public CartItem(Integer cartId, Integer foodId, Integer businessId, Integer userId, Integer quantity) {
        this.cartId = cartId;
        this.foodId = foodId;
        this.businessId = businessId;
        this.userId = userId;
        this.quantity = quantity;
    }
}
